package com.artislong.config;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.api.Advisor;
import org.springframework.ai.chat.prompt.DefaultChatOptions;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY;

/**
 * @author 陈敏
 * @version ChatClientConfiguration.java, v 1.0 2025 03 31 22:20 chenmin Exp $
 * Created on 2025 03 31
 */
@Configuration
public class ChatClientConfiguration {

    /*@Bean
    public ChatClient chatClient(ChatClient.Builder builder) {
        return builder.defaultSystem("你是一个友好的聊天机器人，以海盗的口吻回答问题").build();
    }*/

    @Bean
    public ChatClient chatClient(ChatClient.Builder builder) {
        return builder
                .defaultSystem("你是一个友好的聊天机器人，以{voice}的口吻回答问题")
                .defaultOptions(new DefaultChatOptions())
                .defaultAdvisors(advisorSpec -> advisorSpec.advisors(new Advisor() {
                    @Override
                    public String getName() {
                        return CHAT_MEMORY_CONVERSATION_ID_KEY;
                    }

                    @Override
                    public int getOrder() {
                        return 0;
                    }
                }))
                .defaultTools("parseMovie")
                .build();
    }

}
